﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Data.SQLite;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Schedule
{
    
    public delegate void SubmitHandle();
    public partial class AddCourseForm : Form
    {
        public event SubmitHandle SubmitClick;
        private static string connStr = Properties.Settings.Default.ConnectionString;
        public string sqlCommand;
        public AddCourseForm()
        {

            InitializeComponent();
        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }

        private void OKBtn_Click(object sender, EventArgs e)
        {

            long courseID;
            string courseName;
            int weekday, beginLesson, lastLesson;
            try
            {
                courseID = Int64.Parse(CourseIDTxt.Text);
                 courseName = couseNameTxt.Text;
                 weekday = weekdayTxt.SelectedIndex + 1;
                 beginLesson = Int32.Parse(beginLessonTxt.Text);
                lastLesson = (int)lastLessonNum.Value;
            }
            catch(System.FormatException)
            {
                MessageBox.Show("输入格式不正确 请重新输入");
                return;
            }
            new CourseDataManage().addCourse(courseID,courseName,weekday,beginLesson,lastLesson);
            SubmitClick();
            this.Close();
        }

        private void cancelBtn_Click(object sender, EventArgs e)
        {
            this.Close();

        }
    }
}
